package com.neuedu.guide;


/**
 * 逻辑运算
 */
public class OpreationLogic {


    public static void main(String[] args) {

        int age = 62;
        char gender = '女';
        //允许退休   男士 63

        System.out.println("age = " + age);
        System.out.println("gender = " + gender);

        //逻辑与
        boolean  success = gender =='男'   &&  age >=63;

        System.out.println("逻辑与 success = " + success);




        //逻辑或
        success = ( gender =='男'   &&  age >=63)     ||     (gender =='女'   &&  age >=58);
        System.out.println("逻辑或  success = " + success);



        //逻辑取反    true  -- false    false --true
        boolean b1 = true;

        System.out.println("!b1 = " + !b1);
        System.out.println("!!b1 = " + !!b1);


        System.out.println("(true  && true) = " + (true && true));  // true
        System.out.println("(false  && true) = " + (false && true));  // false
        System.out.println("(true  && false) = " + (true && false));  // false
        System.out.println("(false  && false) = " + (false && false));  // false



        System.out.println("(true  || true) = " + (true || true));  // true
        System.out.println("(false  || true) = " + (false || true));  // true
        System.out.println("(true  || false) = " + (true || false));  // true
        System.out.println("(false  || false) = " + (false || false));  // false



        //逻辑短路
        int numa = 10; // 12 不短路
        int numb = 5;

        boolean result = numa >11 && (numb++)>5;
        System.out.println("result = " + result);  //false
        System.out.println("numb = " + numb);  // 5


        // 算数表达式  --- 数字        逻辑、关系   boolean
         int a = 10 + 20;
         boolean succes = 10 < 20 ;


        //赋值运算    左边变量的 类型
        int num100 = 100;
        boolean b100 = true;

        System.out.println(   ( num100 = 200)  + 100);;

        System.out.println(   !    (b100 = false));



        //三木运算

        int num500 = 450;

        String num500Result = num500 >= 500 ? "数字大于等于500 " : "数字小于500";
        System.out.println("num500 = " + num500);
        System.out.println("num500Result = " + num500Result);


    }





}
